package vn.kiemviec.app.utils;

import android.app.Activity;
import android.graphics.drawable.Drawable;
import android.view.View;
import android.widget.ImageView;
import android.widget.TextView;

public final class ViewHelper {

	
	private ViewHelper() {
	}

	
	@SuppressWarnings("unchecked")
	public static <V extends View> V findView(View view, int viewId) {
		return (V) view.findViewById(viewId);
	}

	
	@SuppressWarnings("unchecked")
	public static <V extends View> V findView(Activity activity, int viewId) {
		return (V) activity.findViewById(viewId);
	}

	
	public static void setText(View v, int id, int stringId) {
		((TextView) v.findViewById(id)).setText(stringId);
	}

	
	public static void setText(View v, int id, CharSequence text) {
		((TextView) v.findViewById(id)).setText(text);
	}

	
	public static void setImage(View v, int id, int drawableId) {
		((ImageView) v.findViewById(id)).setImageResource(drawableId);
	}

	
	public static void setImage(View v, int id, Drawable drawable) {
		((ImageView) v.findViewById(id)).setImageDrawable(drawable);
	}

	
	public static void setColor(View v, int id, int color) {
		((TextView) v.findViewById(id)).setTextColor(color);
	}
}
